const express = require('express');

const app = express()
//静态文件服务器，目录： build
app.use(express.static('build'));

const server = require('http').createServer(app);
//集成websocket服务器
const io = require("socket.io")( server, {
    allowEIO3: true,
    cors: {
      origin: "http://localhost:3000", // from the screenshot you provided
      methods: ["GET", "POST"]
    }
});

io.on('connection', socket => { 
  socket.on('message',(message)=>{
    socket.emit('message', message);
    console.log(message);
  });
  socket.on('method',(message)=>{
    socket.emit('message', message);
    console.log(message);
  });
 });

server.listen(17680, 'localhost',() => {
	console.log('Server url: http://localhost:17680');
	})